<script src="../../../../第五个月/Vue项目/vue1201/src/main.js"></script>
<template>
  <div>
    <a-form-model :layout="form.layout" :model="form" v-bind="formItemLayout">
    <a-form-model-item label="Form Layout">
    <a-radio-group v-model="form.layout">

      <a-radio-button value="horizontal">
        Horizontal
      </a-radio-button>

      <a-radio-button value="vertical">
        Vertical
      </a-radio-button>

      <a-radio-button value="inline">
        Inline
      </a-radio-button>

    </a-radio-group>
  </a-form-model-item>

    <a-form-model-item label="用户名">
      <a-input v-model="form.username" placeholder="请输入用户名" />
    </a-form-model-item>

    <a-form-model-item label="密码">
      <a-input v-model="form.password" placeholder="请输入密码" />
    </a-form-model-item>

    <a-form-model-item :wrapper-col="buttonItemLayout.wrapperCol">

      <a-button type="primary" @click="register">
        注&emsp;册
      </a-button>

    </a-form-model-item>
  </a-form-model>

  </div>
</template>
<script>
export default {
  data() {
    return {
      form: {
        layout: "horizontal",
        username: "",
        password: "",
      },
    };
  },
  computed: {
    formItemLayout() {
      const { layout } = this.form;
      return layout === "horizontal"
        ? {
          labelCol: { span: 4 },
          wrapperCol: { span: 14 },
        }
        : {};
    },
    buttonItemLayout() {
      const { layout } = this.form;
      return layout === "horizontal"
        ? {
          wrapperCol: { span: 14, offset: 4 },
        }
        : {};
    },
  },
  methods: {
    register(){
      let UserInfo=new FormData()
      UserInfo.append("username",this.form.username)
      UserInfo.append("password",this.form.password)
      this.$axios.post('/z/register/',UserInfo)
        .then(res=>{
          alert(res.data.msg)
          console.log(res.data)
          this.$router.push('ant_login')
        })
        .catch(err=>{
          console.log(res.data.msg)
        })
    }
  },
};
</script>
